/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package jse;

import java.text.DecimalFormat;
import java.text.DecimalFormatSymbols;
import java.text.NumberFormat;
import java.text.ParseException;
import java.util.Locale;

/**
 *
 * @author WangShuai
 */
public class NumberFormatTest {

    public static void main(String[] args) throws ParseException {
//        //To format a number for the current Locale:USA
//        System.out.println(NumberFormat.getInstance().format(123456789)); //123,456,789
//        //Specify locale to format number
//        System.out.println(NumberFormat.getInstance(Locale.FRENCH).format(123456789));  //123 456 789
//
//        System.out.println(NumberFormat.getCurrencyInstance().format(123456789.12)); //Default:$123,456,789.12
//
//        System.out.println(NumberFormat.getCurrencyInstance(Locale.CHINA).format(123456789.12));//￥123,456,789.12
//
//        System.out.println(NumberFormat.getPercentInstance().format(0.2525)); //25%
//
//        System.out.println(NumberFormat.getPercentInstance(Locale.CHINA).format(0.2525));//25%
//        
//        NumberFormat nf = NumberFormat.getInstance();
//        nf.setMinimumFractionDigits(4);//至少4位小数  用于format方法  123,456.7890
//        System.out.println(nf.format(123456.789));
//        nf.setParseIntegerOnly(true); //只解析整数部分，用于parse方法  12345
//        System.out.println(nf.parse("12345.678"));
        
        DecimalFormat df = new DecimalFormat("¤#,###", DecimalFormatSymbols.getInstance(Locale.CHINA));
        System.out.println(df.format(12345670.12));
        
    }
}
